package org.martyn.danbodroid.gui;

import org.martyn.danbodroid.R;
import org.martyn.danbooru.types.PostPicture;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PreviewPicture extends LinearLayout
{
	private ImageView imageView;
	private TextView textView;
	private PostPicture postPicture;

	public PreviewPicture(Context context, PostPicture postPicture)
	{
		super(context);

		this.postPicture = postPicture;

		initLayout();
	}

	private void initLayout()
	{
		this.addView(inflate(this.getContext(), R.layout.preview_picture, null));

		imageView = (ImageView) this.findViewById(R.id.imageView);
		textView = (TextView) this.findViewById(R.id.pictureName);

		setPicture(postPicture);

		setText(postPicture);
	}

	private void setPicture(PostPicture postPicture)
	{
		imageView.setImageBitmap(postPicture.getBitmap());
	}

	private void setText(PostPicture postPicture)
	{
		textView.setText(String.valueOf(postPicture.getPost().getId()));
	}

	public PostPicture getPostPicture()
	{
		return postPicture;
	}

	public void setPostPicture(PostPicture postPicture)
	{
		this.postPicture = postPicture;
	}
}
